package com.base.cn.platform.os.service.course.cou.record;

import com.base.cn.platform.os.entity.course.cou.record.CoursePlayRecord;
import com.base.cn.platform.os.entity.course.cou.record.CoursePlayRecordCondition;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.course.CourseBaseService;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 课程播放记录
 *
 * @author SK
 * @since 2018-06-14
 **/
@FeignClient(value = CourseBaseService.appName, configuration = FeignAuthConfig.class)
public interface CoursePlayRecordService extends CourseBaseService {

    /**
     * 保存随堂练习
     * @param examRecordId 随堂练习记录ID
     * @param courseId 购买的课程/套餐ID
     * @param catalogId 目录
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/saveExercises")
    Map<String,Object>  saveExercises(@RequestParam("examRecordId") BigDecimal examRecordId,
                                      @RequestParam("courseId") BigDecimal courseId,
                                      @RequestParam("catalogId") BigDecimal catalogId,
                                      @RequestParam("userId") BigDecimal userId);

    /**
     * 保存课程播放记录
     *
     * @param coursePlayRecord 课程播放记录
     * @return 保存结果
     */
    @RequestMapping(contextPath + "/saveCoursePlayRecord")
    Map<String, Object> saveCoursePlayRecord(@RequestBody Map<String, Object> coursePlayRecord);

    /**
     * 查询课程播放记录列表
     *
     * @param params  课程播放记录查询条件
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @param setCourse  设置课程
     * @param setCreator 设置前台用户
     * @param setCatalogData 是否设置目录数据
     * @param setCatalogTeacher 是否设置目录讲师
     * @return 课程播放记录列表zxcx
     */
    @RequestMapping(contextPath +"/findCoursePlayRecordPage")
    Map<String,Object>  findCoursePlayRecordPage(@RequestBody Map<String, Object> params,
                                                 @RequestParam(value = "currentPage") int currentPage,
                                                 @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,
                                                 @RequestParam(value = "setCourse") boolean setCourse,
                                                 @RequestParam(value = "setCreator") boolean setCreator,
                                                 @RequestParam("setCatalogData") boolean setCatalogData,
                                                 @RequestParam("setCatalogTeacher") boolean setCatalogTeacher);

    /**
     * 查询用户学习了多少个课程
     * @param userId 用户ID
     * @return 已学习的课程数据
     */
    @RequestMapping(contextPath + "/queryUserStudyCourseNum")
    Integer queryUserStudyCourseNum(BigDecimal userId);

    /**
     * 查询用户总学习时间
     * @param userId 用户ID
     * @param courseId 课程ID
     * @return 学习时间
     */
    @RequestMapping(contextPath + "/queryUserStudySumTime")
    Integer queryUserStudySumTime(@RequestParam("userId") BigDecimal userId,
                                  @RequestParam("courseId") BigDecimal courseId);

//    /**
//     * 查询用户课程总学习时间列表
//     * @param userId 用户ID
//     * @param courseIds 课程ID串
//     * @return 学习时间
//     */
//    @RequestMapping(contextPath + "/queryUserStudySumTimeList")
//    Integer queryUserStudySumTimeList(@RequestParam("userId") BigDecimal userId,
//                                  @RequestParam("courseIds") String courseIds);

    /**
     * 查询用户某一周的学习时间
     * @param userId 用户ID
     * @param courseId 课程ID
     * @return 学习时间
     */
    @RequestMapping(contextPath + "/queryUserWeekStudySumTime")
    Integer queryUserWeekStudySumTime(@RequestParam("userId") BigDecimal userId,
                                      @RequestParam("courseId") BigDecimal courseId);

    /**
     * 查询用户对课程的学习的排行名次（根据学习时间进行排序）
     * @param userId 用户ID
     * @param courseId 课程ID
     * @return 排名名字
     */
    @RequestMapping(contextPath +"/queryUserStudyCourseRankings")
    Integer queryUserStudyCourseRankings(@RequestParam("userId") BigDecimal userId,
                                         @RequestParam("courseId") BigDecimal courseId);

    /**
     * 查询学习时间排行第一的用户ID
     * @param courseId 课程ID
     * @return 用户ID
     */
    @RequestMapping(contextPath +"/queryUserStudyCourseRankOne")
    BigDecimal queryUserStudyCourseRankOne(@RequestParam("courseId") BigDecimal courseId);

    /**
     * 查询学习时间排行第一的用户对象
     * @param courseId 课程ID
     * @return 用户ID
     */
    @RequestMapping(contextPath + "/queryUserStudyCourseRankOneUser")
    Map<String,Object> queryUserStudyCourseRankOneUser(@RequestParam("courseId") BigDecimal courseId);

    /**
     * 获取用户最后一个播放的目录节点
     * @param userId 用户ID
     * @return CoursePlayRecord
     */
    @RequestMapping(contextPath + "/getUserLastPlayCourseRecord")
    Map<String,Object> getUserLastPlayCourseRecord(@RequestParam("userId") BigDecimal userId);

    /**
     * 导出学习记录execl
     * @param condition
     * @param pageSize
     * @return
     * @throws Exception
     */
    @RequestMapping(contextPath +"/downloadExcelDetailsList")
    ResponseEntity<byte[]> downloadExcelDetailsList(@RequestBody Map condition,
                                                    @RequestParam(value = "pageSize") int pageSize) throws Exception;

    /**
     * 创建用户的学习记录表、学习明细表
     * @param userId 用户ID
     */
    @RequestMapping(contextPath + "/createUserPlayRecordTable")
    void createUserPlayRecordTable(@RequestParam("userId") BigDecimal userId);

    /**
     * 查询用户学习列表
     * @param condition
     * @return
     */
    @RequestMapping(contextPath + "/findCoursePlayRecordList")
    List<CoursePlayRecord> findCoursePlayRecordList(@RequestBody CoursePlayRecordCondition condition);

    @RequestMapping(contextPath+"/findCourseStatis")
    Map<String, Object> findCourseStatis(@RequestParam("courseId") BigDecimal courseId);



    /**
     * 查询课程学习走势统计（学习人数，学习时长）
     * @param dataKey
     * @param dataQueryCondition
     * @return
     */
    @RequestMapping(contextPath + "/queryCourseStudyStatis")
    Map<String, Object> queryCourseStudyStatis(
                                               @RequestParam("courseId")BigDecimal courseId,
                                               @RequestBody Map<String, Object> dataQueryCondition);

    /**
     * 课程完成率走势统计（学习人数，学习时长）
     * @param dataKey
     * @param dataQueryCondition
     * @return
     */
    @RequestMapping(contextPath + "/queryCourseFinishStatis")
    Map<String, Object> queryCourseFinishStatis(
                                                @RequestParam("courseId")BigDecimal courseId,
                                                @RequestBody Map<String, Object> dataQueryCondition);

    /**
     * 直播统计
     * @param courseId
     * @return
     */
    @RequestMapping(contextPath+"/queryLiveStatis")
    Map<String, Object> queryLiveStatis(
                                        @RequestParam("courseId") BigDecimal courseId,
                                        @RequestParam(value = "materialId",required = false)BigDecimal materialId,
                                        @RequestParam(value = "catalogId",required = false)BigDecimal catalogId);

    /**
     * @param materialId 素材id
     * @param pageSize   页容量
     * @param pageNum    页码
     * @return
     */
    @RequestMapping(contextPath+"/getInteractivePage")
    PageInfo<Map<String, Object>> getInteractivePage(
                                                     @RequestParam("materialId") BigDecimal materialId,
                                                     @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize,
                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum);


    /**
     * @param materialId 素材id
     * @param pageSize   页容量
     * @param pageNum    页码
     * @return
     */
    @RequestMapping(contextPath+"/getChatMsgPage")
    PageInfo<Map<String, Object>> getChatMsgPage(
                                                 @RequestParam("materialId") BigDecimal materialId,
                                                 @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize,
                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum);

    /**
     * @param materialId 素材id
     * @param pageSize   页容量
     * @param pageNum    页码
     * @return
     */
    @RequestMapping(contextPath+"/getRollCallPage")
    PageInfo<Map<String, Object>> getRollCallPage(
                                                  @RequestParam("materialId") BigDecimal materialId,
                                                  @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize,
                                                  @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum);

    /**
     * 查询课程学习走势统计（学习人数，学习时长）
     * @param dataQueryCondition
     * @return
     */
    @RequestMapping(contextPath + "/queryLiveOnlineStatis")
    Map<String, Object> queryLiveOnlineStatis(
                                              @RequestParam("courseId")BigDecimal courseId,
                                              @RequestBody Map<String, Object> dataQueryCondition);

    @RequestMapping(contextPath + "/findUserCatalogDuration")
    Integer findUserCatalogDuration(@RequestParam("userId") BigDecimal userId,
                                    @RequestParam("courseId") BigDecimal courseId,
                                    @RequestParam("catalogId") BigDecimal catalogId);


}
